package com.guigu.liuzhireng.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.liuzhireng.mapper.EducationalMapper;
import com.guigu.liuzhireng.pojo.Educational;
import com.guigu.liuzhireng.pojo.PageVo;
import com.guigu.liuzhireng.service.EducationalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EducationalServiceImpl implements EducationalService {

    @Autowired
    EducationalMapper educationalMapper;

    @Override
    public int insert(Educational educational) {
        return  educationalMapper.insert(educational);
    }

    @Override
    public int update(Educational educational) {
        return educationalMapper.updateByPrimaryKeySelective(educational);
    }

    @Override
    public int delete(Integer eid) {
        return educationalMapper.deleteByPrimaryKey(eid);
    }

    @Override
    public PageVo<Educational> Page(Educational educational,int num,int size) {
        PageHelper.startPage(num,size);
        List<Educational> list = educationalMapper.EducationalAll(educational);
        PageInfo<Educational> pageInfo = new PageInfo<>(list);

        PageVo<Educational> pageVo = new PageVo<>();
        pageVo.setTotal(pageInfo.getTotal());
        pageVo.setRows(pageInfo.getList());
        return pageVo;
    }
}
